<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        .box {
            width: 100px;
            height: 100px;
            background-color: rgb(153, 78, 78);
            display: inline-block;
        }
    </style>
</head>

<body>
    <button>全都变色</button><br>
    <div class="box"></div>
    <div class="box"></div>
    <div class="box"></div>
    <script>
        var boxs = document.querySelectorAll('.box');
        var btn = document.querySelector('button');
        btn.onclick = function() {
            for (var box of boxs) {
                box.style.backgroundColor = "yellow"
            }
        }
    </script>
</body>

</html>